import 'package:Smart/pages/productor007/studytest/flutter_boss/item/joblist_item.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/model/job.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_boss/item/joblist_item.dart';
// import 'package:flutter_boss/model/job.dart';


class TabPage extends StatefulWidget {
  TabPage({Key key}) : super(key: key);

  @override
  _TabPageState createState() => _TabPageState();
}

class _TabPageState extends State<TabPage> {
  List<Job> _jobs = [];
  @override
  void initState() {
    super.initState();
    getJobList();
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount:_jobs.length, 
        itemBuilder: buildJobItem
        // itemBuilder: _buildListItem
      );
  }

  Widget buildJobItem(BuildContext context, int index) {
    Job job = _jobs[index];
    var jobItem = new InkWell(
      onTap: () {
        showDialog(
            context: context,
            child: AlertDialog(
              content: Text(
                "尽情期待",
                style: TextStyle(fontSize: 20.0),
              ),
            ));
      },
      child: new JobListItem(job)
    );
    return jobItem;
  }

   void getJobList() {
    setState(() {
      _jobs = Job.fromJson("""
        {
          "list":[
            {
              "name":"前端开发工程师",
              "cname":"航易大数据研究院",
              "size":"C轮",
              "salary":"25k-45k",
              "username":"谭鹏",
              "title":"HR",
              "address":"江北区 观音桥"
            },
            {
              "name":"HTML5前端工程师",
              "cname":"重庆鹏领房滴",
              "size":"C轮",
              "salary":"40k-45k",
              "username":"张先生",
              "title":"技术总监",
              "address":"渝北区 财富中心"
            },
            {
              "name":"前端开发工程师",
              "cname":"航易大数据研究院",
              "size":"C轮",
              "salary":"25k-45k",
              "username":"谭鹏",
              "title":"HR",
              "address":"江北区 观音桥"
            },
            {
              "name":"HTML5前端工程师",
              "cname":"重庆鹏领房滴",
              "size":"C轮",
              "salary":"40k-45k",
              "username":"张先生",
              "title":"技术总监",
              "address":"渝北区 财富中心"
            },
            {
              "name":"前端开发工程师",
              "cname":"航易大数据研究院",
              "size":"C轮",
              "salary":"25k-45k",
              "username":"谭鹏",
              "title":"HR",
              "address":"江北区 观音桥"
            },
            {
              "name":"HTML5前端工程师",
              "cname":"重庆鹏领房滴",
              "size":"C轮",
              "salary":"40k-45k",
              "username":"张先生",
              "title":"技术总监",
              "address":"渝北区 财富中心"
            },
            {
              "name":"前端开发工程师",
              "cname":"航易大数据研究院",
              "size":"C轮",
              "salary":"25k-45k",
              "username":"谭鹏",
              "title":"HR",
              "address":"江北区 观音桥"
            },
            {
              "name":"HTML5前端工程师",
              "cname":"重庆鹏领房滴",
              "size":"C轮",
              "salary":"40k-45k",
              "username":"张先生",
              "title":"技术总监",
              "address":"渝北区 财富中心"
            }
          ]
        }
      """);
    });
  }
}